#include <stdbool.h>
#include <stdio.h>
int count = 0;
bool lock = true;
bool TS(bool *lock)
{   bool old;
    old = *lock;
    *lock = true;
	return old;
}
void countproc()
{
    while(TS(&lock));
    count++;
    printf("count:%d\n",count); //释放
    lock = false;
}
main()
{ 
	printf("Begin\n");
	int i;
	for( i=0;i<2;i++)
		countproc();
	printf("End\n");
} 

